<?php
declare (strict_types=1);

namespace app\admin\controller;

use app\common\logic\RouteMenuLogic;
use app\common\model\DepartmentModel;
use app\common\model\RouteMenuModel;
use think\facade\Log;
use think\facade\Request;

/**=========================================
 * Copyright © 2023-2024, WICMS.CN. All Rights Reserved
 * Project Name: WiCMS
 * Description: 菜单控制器
 * Author: jason
 * Email: 52527998@QQ.COM
 * Date: 2024/10/12
 * Time: 下午5:02
 * File: app\admin\controller\Menu.php
 * =========================================
 */
class Menu extends BaseModule
{

    public function initialize(): void
    {
        parent::initialize();
    }

    /**
     * 获取路由导航菜单
     *
     * @return void
     */
    public function get_async_menu(): void
    {
        $menuList = RouteMenuLogic::getRouteList();
        $this->success('获取成功', $menuList);
    }

    public function get_menu_list(): void
    {
        $condition     = Request::get('');
        if (empty($condition)){
            $condition = [
                ['menu_type','=','menu'],
                ['id','>',1]
            ];
        }
        $menuList = RouteMenuLogic::getList($condition, false);
        $this->success('获取成功', $menuList);
    }

    public function save_data(): void
    {
        $data   = Request::post('');
        $result = RouteMenuLogic::saveData($data);
        if ($result) {
            $this->success('保存成功');
        } else {
            $this->error($result);
        }
    }

    public function delete():void
    {
        $id = input('get.id/d', 0,'intval');

    }


    public function get_role_menu(): void
    {
        $menuList = RouteMenuLogic::getRouteListForRole();
        $this->success('success',$menuList);
    }

}